export CXX     = g++
export CFLAGS  = -fPIC -g -Wall -pedantic -O2
export LFLAGS  = -L$(CURDIR) -L/usr/X11R6/lib -lXpm -lXext -lX11 -lwmapp

SOURCES = $(wildcard *.cc)
OBJECTS = $(SOURCES:.cc=.o)

libwmapp.a: $(OBJECTS)
	ar rcs libwmapp.a $^

%.d: %.cc
	@set -e; $(CXX) -MM $(CFLAGS) $< | sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@; \
		   [ -s $@ ] || rm -f $@

-include $(SOURCES:.cc=.d)

%.o:
	$(CXX) $(CFLAGS) -c $< -o $@

clean:
	-rm -f tags *.o *.d *\~
	-find . -name .xvpics | xargs rm -rf

distclean: dist-clean

dist-clean: clean
	-rm -f libwmapp.a

.PHONY:	all clean distclean dist-clean

